This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Jan 12, 2015, 4:53 AM
5 Posts

Updating 'other' documents from an XPage

  • Category: Server Side JavaScript
  • Platform: All
  • Release: All
  • Role: Developer
  • Tags:
  • Replies: 1

Need some ideas...

I have an XPage that represents a document that also has some 'associated' response documents. I need a way to present to the user a form / dialog to allow them to assign several values - some of which will update the XPage parent they are on, and some values will update some of the response documents (different ones).

I thought I would try an XPage to allow them to select all the values and then maybe call an agent to perform the updates - but, how do I pass the values to the agent? Does an XPage by itself, without a backend form work so that you can pass it as a document to the agent?

Or is there a better way to do what I need to do? Seems like a potentially common need - I am in a document, need to set some values and update other documents as a result...

Thanks!

Mike Davis

Jan 12, 2015, 7:10 PM
453 Posts
Not sure I understand you question but...

3. 1. You could put your code in the submit button to do the update in SSJS. But this would require the user to have read/write access to the DB, however, you can also open the DB in the SSJS with

thisDB = sessionAsSignerWithFullAccess.getDatabase("","");
    thisDB.openByReplicaID(serverName,repID);

now you are running with the signers rights to the DB regardless of the individual users rights. So if the signer of the DB (Probably the Server ID) has all rights to the DB so does the DB.

2. Because an XPage can have several different dataSources on the same page you could bind each field to the correct dataSource and XPages takes care of the rest. 

a third option that I have used in both XPages and in Native Notes is have your XPage bound to a single dataSource say transDoc. Then have you Save/Submit button save the dataSource then run your background agent using something like this:

var agent:NotesAgent = database.getAgent("WFS Process Actions");
        agent.runOnServer();
        agent.recycle()

The runOnServer method runs the agent with the Servers ID so you should not have any access issues. In my agent "WFS ProcessActions" I look in the transaction view grab any documents in the view and run the agent against them. In fact the agent could be a scheduled agent and run every few minutes or whatever is appropriate. This works nicely if the process has to do a lot of work as it frees up the client quicker, down side the documents are not updated immediately.

3.   Another way would be to write a JAVA Bean to handle the whole thing, and this is a way that I'm looking into but I have so much legacy code in LS that I found the best method for me was to use option 2 above. If I was starting from scratch I would probably write the JAVA Bean, and some day I full expect to migrate to this method, but my biggest issue was to get an existing application working.. 

So the answer to your question is YES, but there are a lot of different ways to address the same problem depending on what works best for you. Plus I would guess that one could devise several additional methods to solve the problem. Oh one more is that the controls on an XPage don't have to be bound to a dataSource they can be bound to Scoped Variables, Oh and one more you can create a dummy dataSource for the XPage that is never saved. So XPages gives you a tremendous number of options. Sometimes so many of them that it had to wrap ones head around them. So the answer is does it work in your environment.


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal